package main

import (
	"fmt"
)

type FileDownLoader interface {
	//打开网络连接o
	openConnection()
	//从给定的网络资源地址下载文件
	downloadFromUrl(downLoadUrl string) []byte
	//将下载的文件保存到本地
	saveToLocalDisk(fileLocation string)
	//关闭网络连接
	closeConnection()
}

type imageFile struct {
	width  int32
	height int32
}

func (imageFileInstance imageFile) dispaly() {
	fmt.Println("图片内容")
}

func (imageFileInstance imageFile) openConnection() {
	fmt.Println("准本下载图片")
}
func (imageFileInstance imageFile) downloadFromUrl(remoteUrl string) []byte {
	fmt.Println("正在下载图片文件")
	return []byte{}
}

func (imageFileInstance imageFile) downLoadFromUrl(remoterUrl string) []byte {
	fmt.Println("正在下载图片")
	return []byte{}
}

func (imageFileInstance imageFile) saveToLocalDisk(LocalFileUrl string) {
	fmt.Println("正在保存图片文件")
}

func (imageFileInstance imageFile) closeConnectiion() {
	fmt.Println("下载图片文件成功,关闭网络连接")
}

type AudioFile struct {
	duration int64
}

func (audioFileInstance AudioFile) play() {
	fmt.Println("播放音频文件")
}
func (audioFileInstance AudioFile) openConnection() {
	fmt.Println("准本下载音频,打开网络连接")
}
func (audioFileInstance AudioFile) downloadFromUrl(string) (data []byte) {
	fmt.Println("正在下载音频文件")
	data = []byte{}
	return
}

func (audioFileInstance AudioFile) downLoadFromUrl(string2 string) (data []byte) {
	fmt.Println("正在下载音频文件")
	data = []byte{}
	return
}

func (audioFileInstance AudioFile) saveToLocalDisk(string2 string) {
	fmt.Println("正在保存音频文件")
}

func (audioFileInstance AudioFile) closeToLocalDisk(string2 string) {
	fmt.Println("下载音频文件成功,关闭网络连接")
}
func main() {
	//var fileDownloader FileDownloader
	//imageFile:=ImageFile{}
	//fileDownloader=imageFile
	//fileDownloader.openConnection()
	//fileDownloader.downloadFromUrl("https://xxx.xxx.xxx/xxx.jpg")
	//fileDownloader.saveToLocalDisk("D:\\xxx.jpg")
	//fileDownloader.closeConnection()
	//audioFile:=AudioFile{}
	//fileDownloader=audioFile
	//fileDownloader.openConnection()
	//fileDownloader.downloadFromUrl("https://xxx.xxx.xxx/xxx.m4a")
	//fileDownloader.saveToLocalDisk("D:\\xxx.m4a")
	//fileDownloader.closeConnection()

}
